<div class="layuimini-main">

  <div class="layui-form layuimini-form">

    <div class="layui-form-item">
      <label class="layui-form-label required">投诉类型</label>
      <div class="layui-input-block">
        <select name="comId" lay-verify="required"  id="typeId2" lay-search="">
          <option value="">请选择保修类型</option>
        </select>
      </div>
    </div>

    <div class="layui-form-item layui-form-text">
      <label class="layui-form-label">备注信息</label>
      <div class="layui-input-block">
        <textarea name="remarks" class="layui-textarea" placeholder="请输入备注信息"></textarea>
      </div>
    </div>

    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
      </div>
    </div>
  </div>
</div>
<script>
  layui.use(['form', 'table'], function () {
    var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            $ = layui.$;

    /**
     * 初始化表单，要加上，不然刷新部分组件可能会不加载
     */
    form.render();

    //获取费用类型 并渲染数据到select标签
    $.get("repair/queryAll",{},function (data) {
      var list=data;
      var select =document.getElementById("typeId2");
      if(list!=null || list.size()>0){
        for(var c in list){
          var option=document.createElement("option");
          option.setAttribute("value",list[c].id);
          option.innerText=list[c].name;
          select.appendChild(option);
        }
      }
      form.render('select');
    },"json");

    // 当前弹出层，防止ID被覆盖
    var parentIndex = layer.index;

    //监听提交
    form.on('submit(saveBtn)', function (data) {
      //获取表单中的数据信息
      var datas=data.field;
      console.log(datas);
      addOrUpdateSubmit($,"repair/add",datas);
      return false;
    });

  });
</script>